#include <stdlib.h>
#include "fileutil.h"
#include "my_error.h"

#include <json/json_tokener.h>
#include <json/json.h>

int main(int argc ,char *argv[])
{
   char *buff;
   int ret = readfile(argv[1],&buff);
   printf("ret:%d buff:%s\n",ret,buff);
   free(buff);

   pool_t *pool = create_pool(1024);
   ret = readfile_by_pool(argv[1],&buff,pool); 
   printf("ret:%d buff:%s\n",ret,buff);

   struct json_object  *json_obj;
    
   json_obj = json_tokener_parse(buff); 
   printf("json:%s\n",json_object_to_json_string(json_obj));

   struct json_object *new_obj;
   new_obj = json_object_object_get(json_obj,"name"); 
   printf("name:%s\n",json_object_get_string(new_obj));
 
   json_object_put(json_obj); 
    
   destroy_pool(pool);
   return 0;
}
